import time

from appium import webdriver
import unittest
from appium.webdriver.common.appiumby import AppiumBy

# _*_ coding: utf-8 _*_


"""
Time:     2022/3/30 13:48
Author:   HANAMAKI
Version:  V 0.1
File:     AppiumTest.py
Describe: 
"""

# 想要编写 appium 的自动化测试的脚本
"""
    1、下载对应的  模块 来使用 
    pip install Appium-Python-Client
"""


class AppiumTestcase(unittest.TestCase):
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        desired_caps = dict(
            platformName='Android',
            appActivity='com.iBookStar.activityOff.Splash',
            appPackage='com.iBookStar.activityOff',
            deviceName='127.0.0.1:62001',
        )
        cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        cls.driver.implicitly_wait(10)

    def test_ibooks(self):
        print('启动成功')
        button = self.driver.find_element(AppiumBy.ID, "com.iBookStar.activityOff:id/go")
        text = button.text
        print(text)
        button.click()

    @classmethod
    def tearDownClass(cls) -> None:
        cls.driver.quit()


if __name__ == '__main__':
    unittest.main()
